import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

//注册驱动的另一种方式(常用)
public class jdbcdemo04 {
    public static void main(String[] args) {
        try{
            //1.注册驱动
            //DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            Class.forName("com.mysql.jdbc.Driver");
            //2.获取连接
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/text","root","123456");
            System.out.println(conn);
        }catch (SQLException e){
            e.printStackTrace ();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
